﻿using System;
using Super_Management_Mayhem.Content.Animations;
using Super_Management_Mayhem.Content.Animations.Manager;
using Super_Management_Mayhem.Content.Spritesheet.Player;
using Transformable_Engine_v2.Engine.Animation.ColorAnimation;
using Transformable_Engine_v2.Engine.Animation.FrameAnimation;
using Transformable_Engine_v2.Engine.Animation.PositionAnimation;
using Transformable_Engine_v2.Engine.Animation.Trajectory;
using Transformable_Engine_v2.Engine.GameObjects.Containers;
using Transformable_Engine_v2.Engine.Global;
using Transformable_Engine_v2.Engine.Graphics;
using Transformable_Engine_v2.Engine.Transformable_Math.Geometry;

namespace Super_Management_Mayhem.Screens.Playing.Players.Manager
{
    public partial class Manager
    {
        private void HandleKeyPressDeadState(Input input) {}

        private void HandleKeyReleaseDeadState(Input input) {}

        private void InitializeDeadState()
        {
            if(_isCarrying)
                DestroyCarriedObject();

            _character.ClearAnimation<FrameAnimation>();

            switch(_latestDirection) 
            {
                case Direction.Left:
                    _character.OriginAbsolute = new TE_Vector2(8, 26);
                    _character.AddAnimations(new FrameAnimation(new DeathLeft(SpriteSheetPath)));
                    break;
                case Direction.Right:
                    _character.OriginAbsolute = new TE_Vector2(23, 26);
                    _character.AddAnimations(new FrameAnimation(new DeathRight(SpriteSheetPath)));
                    break;
            }
            _character.Color = Color.White;
            _character.AddAnimations(new ColorAnimation(new LinearEasing(), Color.Transparent, 500, false, 2500));
            _character.AddAnimations(new ColorAnimation(new SinusTrajectory(1), Color.Transparent, 150, true, 0));

            var ghost = new ImageContainer {
                                               Position = new TE_Vector2(0, 8),
                                               Sprite = ManagerSheet.GetSprite(ManagerSheet.Ghost.Ghost0),
                                               Origin = TE_Rectangle.Alignment.BottomMiddle,
                                               Color = Color.Transparent,
                                           };

            ghost.AddAnimations(new PositionUniformLinearAnimation(0, new TE_Vector2(0, -1)));
            ghost.AddAnimations(new ColorAnimation(new LinearEasing(), new Color(Color.White, 200), 500, false, 0));
            ghost.AddAnimations(new ColorAnimation(new LinearEasing(), Color.Transparent, 500, false, 2500));
            ghost.AddAnimations(new FrameAnimation(new Ghost(SpriteSheetPath)));

            _player.AddChildren(ghost);

            Die(3000);
        }

        private void UpdateDeadState(TimeSpan gameTime) {}
    }
}